import axios from 'axios'

const server = axios.create({
    baseURL: '',
    timeout: 5000
})

// 请求拦截
server.interceptors.request.use(config => {
    if(localStorage.getItem('token')) {
        var token = localStorage.getItem('token')
    }
    config.headers.token = token
    return config
}, err => {
    // 请求报错时的提示逻辑
    console.log(err)
})

// 响应拦截

server.interceptors.response.use(res => {
    return res
}, err => {
    // 几种处理请求响应时出错的提示信息
    console.log(err)
})

export default server